<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!-- 导入的三个包真的很重要，切记不要忘记 -->
<%@page import="java.sql.DriverManager" %>
<%@page import="java.sql.Connection" %>
<%@page import="java.sql.PreparedStatement" %>


<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>操作反馈</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        .fakeimg {
            height: 200px;
            background: #aaa;
        }

        td, th {
            text-align: center;
        }

        a {
            text-decoration: none
        }

    </style>
</head>

<body>
<!-- 解决中文乱码的问题 -->
<%request.setCharacterEncoding("UTF-8"); %>
<%
    request.setCharacterEncoding("utf-8");
    String StudentNumber = request.getParameter("StudentNumber");

%>
<%
    try {
        Class.forName("com.mysql.jdbc.Driver");//加载数据库驱动，注册到驱动管理器
        //out.print("<h1 class=\"lead\">加载数据库驱动成功！！！</h>");
        String url = "jdbc:mysql://localhost:3306/servlet";//数据库连接字符串
        String name = "root";//
        String password = "root";
        Connection conn = DriverManager.getConnection(url, name, password);
        //创建connection连接，

        String sql = "delete from t_info where StudentNumber=" + StudentNumber + "";
        //添加信息的sql语句
        PreparedStatement ps = conn.prepareStatement(sql);
        //获取PreparedStatement


        int row = ps.executeUpdate();//执行更新操作，返回所影响的行数
        if (row > 0) {
            //out.print("<h1>成功添加了 " + row + " 条数据！！！</h1>");
        }
        ps.close();
        conn.close();
    } catch (Exception e) {
        out.print("失败");
        e.printStackTrace();
    }

%>



<br>
<script>
    alert("删除成功")
</script>>
<%
    //定时跳转
    response.setHeader("refresh", "0;URL=index.jsp");
%>
</body>
</html>